﻿package program;

public class GameBoard {
	private Field[] BoardField = new Field[40];
	
	//Types: Start, Street, Luck, Shipping, Brewery, Jail, Tax, Refuge
	/*Colors: 
	0 = "Null", 
	1 = Blue, 
	2 = Orange, 
	3 = GreenYellow, 
	4 = LightBlue, 
	5 = Red, 
	6 = White, 
	7 = Yellow, 
	8 = "8",
	9 = Brewery
	10 = Shipping */
	String[][] fdArray = {
            {"Start",				"Start",	"0",	"4000"},
            {"Rødovrevej",			"Street",	"1",	"1200"},
            {"Prøv Lykken",			"Luck",		"0",	"0"},
            {"Hvidorevej",			"Street",	"1",	"1200"},
            {"Skat",				"Tax",		"0",	"4000"}, //Skat kan også have -10%
            {"Scandlines",			"Shipping",	"10",	"4000"},
            {"Roskildevej",			"Street",	"2",	"2000"},
            {"Prøv Lykken",			"Luck",		"0",	"0"},
            {"Valbye Langgade",		"Street",	"2",	"2000"},
            {"Allégade",			"Street",	"2",	"2400"},
            {"På besøg i fængsel",	"Refuge",	"0",	"0"}, //på besøg derfor = refuge
            {"Frederiksberg Allé",	"Street",	"3",	"2800"},
            {"Tuborg Squash",		"Brewery",	"9",	"3000"},
            {"Bülowsvej",			"Street",	"3",	"2800"},
            {"Gl. Kongevej",		"Street",	"3",	"3200"},
            {"Mols-Linien",			"Shipping",	"10",	"4000"},
            {"Bernstorffsvej",		"Street",	"4",	"3600"},
            {"Prøv Lykken", 		"Luck",		"0",	"0"},
            {"Hellerupvej",			"Street",	"4",	"3600"},
            {"Strandvejen",			"Street",	"4",	"4000"},
            {"P-plads",				"Refuge",	"0",	"0"},
            {"Trianglen",			"Street",	"5",	"4400"},
            {"Prøv Lykken",			"Luck",		"0",	"0"},
            {"Østerbrogade",		"Street",	"5",	"4400"},
            {"Grønningen",			"Street",	"5",	"4800"},
            {"Scandlines",			"Shipping",	"10",	"4000"},
            {"Bredgade",			"Street",	"6",	"5200"},
            {"Kgs. Nytorv",			"Street",	"6",	"5200"},
            {"Coca Cola",			"Brewery",	"9",	"3000"},
            {"Østergade",			"Street",	"6",	"5600"},
            {"I fængsel",			"Jail",		"0",	"0"},
            {"Amagertorv",			"Street",	"7",	"6000"},
            {"Vimmelskaftet",		"Street",	"7",	"6000"},
            {"Prøv Lykken",			"Luck",		"0",	"0"},
            {"Nygade",				"Street",	"7",	"6400"},
            {"Scandlines",			"Shipping",	"10",	"4000"},
            {"Prøv Lykken",			"Luck",		"0",	"0"},
            {"Frederiksberggade",	"Street",	"8",	"7000"},
            {"Skat",				"Tax",		"0",	"2000"},
            {"Rådhuspladsen",		"Street",	"8",	"8000"},
        };
	
	public void sortFieldData(){
		int[] colorArray = new int[11];
		
		for(int i = 0; i <= 39; i++){			
			int color = Integer.parseInt(fdArray[i][2]);
			colorArray[color]++;
			int colorNr = colorArray[color];
			
			createFields(i, color, colorNr);
		}
	}
	
	//Start, Street, Luck, Shipping, Brewery, Jail, Tax, Refuge
	//data[] = Name, Type, Color, Payment
	private void createFields(int nr, int color, int colorNr){
		int payment = Integer.parseInt(fdArray[nr][3]);
		
		if(fdArray[nr][1].equals("Start")){
			BoardField[nr] = new Refuge(nr, payment, fdArray[nr][0], fdArray[nr][1], color, colorNr);
		}
		else if(fdArray[nr][1].equals("Street")){
			BoardField[nr] = new Street(nr, payment, fdArray[nr][0], fdArray[nr][1], color, colorNr);
		}
		else if(fdArray[nr][1].equals("Luck")){
			BoardField[nr] = new Luck(nr, payment, fdArray[nr][0], fdArray[nr][1], color, colorNr);
		}
		else if(fdArray[nr][1].equals("Shipping")){
			BoardField[nr] = new Shipping(nr, payment, fdArray[nr][0], fdArray[nr][1], color, colorNr);
		}
		else if(fdArray[nr][1].equals("Brewery")){
			BoardField[nr] = new Brewery(nr, payment, fdArray[nr][0], fdArray[nr][1], color, colorNr);
		}
		else if(fdArray[nr][1].equals("Jail")){
			BoardField[nr] = new Jail(nr, payment, fdArray[nr][0], fdArray[nr][1], color, colorNr);
		}
		else if(fdArray[nr][1].equals("Tax")){
			BoardField[nr] = new Tax(nr, payment, fdArray[nr][0], fdArray[nr][1], color, colorNr);
		}
		else if(fdArray[nr][1].equals("Refuge")){
			BoardField[nr] = new Refuge(nr, payment, fdArray[nr][0], fdArray[nr][1], color, colorNr);
		}
	}
	public Field getField(int terningSum){
		return BoardField[terningSum];
	}
}
